<?php
$id = isset($_GET['id']) ? $_GET['id'] : 'cetv1';
$n = array(
    'cetv1' => 695,
    'cetv2' => 696,
    'cetv3' => 697,
    'cetv4' => 698,
);
$ch = curl_init('http://app.cetv.cn/video/player/stream?site_id=10001&stream_id=' . $n[$id]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
$playUrl = json_decode($data)->stream;
$pathArr = explode("/", $playUrl);
$endPath = $pathArr[sizeof($pathArr) - 1];
$endPath = str_replace(".m3u8", "", $endPath);
$c = curl_init($playUrl);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_HTTPHEADER, array("Referer: http://app.cetv.cn"));
$result = curl_exec($c);
curl_close($c);
$ts = str_replace($endPath, "http://txycsbl.centv.cn/zb/" . $endPath, $result);
print_r($ts);
?>